package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsHotelreviews;
import com.hbms.business.service.IHotelbmsHotelreviewsService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 酒店评价Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/hotelreviews")
public class HotelbmsHotelreviewsController extends BaseController
{
    @Autowired
    private IHotelbmsHotelreviewsService hotelbmsHotelreviewsService;

    /**
     * 查询酒店评价列表
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsHotelreviews hotelbmsHotelreviews)
    {
        startPage();
        List<HotelbmsHotelreviews> list = hotelbmsHotelreviewsService.selectHotelbmsHotelreviewsList(hotelbmsHotelreviews);
        return getDataTable(list);
    }

    /**
     * 导出酒店评价列表
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:export')")
    @Log(title = "酒店评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsHotelreviews hotelbmsHotelreviews)
    {
        List<HotelbmsHotelreviews> list = hotelbmsHotelreviewsService.selectHotelbmsHotelreviewsList(hotelbmsHotelreviews);
        ExcelUtil<HotelbmsHotelreviews> util = new ExcelUtil<HotelbmsHotelreviews>(HotelbmsHotelreviews.class);
        util.exportExcel(response, list, "酒店评价数据");
    }

    /**
     * 获取酒店评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:query')")
    @GetMapping(value = "/{reviewId}")
    public AjaxResult getInfo(@PathVariable("reviewId") Long reviewId)
    {
        return success(hotelbmsHotelreviewsService.selectHotelbmsHotelreviewsByReviewId(reviewId));
    }

    /**
     * 新增酒店评价
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:add')")
    @Log(title = "酒店评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsHotelreviews hotelbmsHotelreviews)
    {
        return toAjax(hotelbmsHotelreviewsService.insertHotelbmsHotelreviews(hotelbmsHotelreviews));
    }

    /**
     * 修改酒店评价
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:edit')")
    @Log(title = "酒店评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsHotelreviews hotelbmsHotelreviews)
    {
        return toAjax(hotelbmsHotelreviewsService.updateHotelbmsHotelreviews(hotelbmsHotelreviews));
    }

    /**
     * 删除酒店评价
     */
    @PreAuthorize("@ss.hasPermi('business:hotelreviews:remove')")
    @Log(title = "酒店评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reviewIds}")
    public AjaxResult remove(@PathVariable Long[] reviewIds)
    {
        return toAjax(hotelbmsHotelreviewsService.deleteHotelbmsHotelreviewsByReviewIds(reviewIds));
    }
}
